
const express = require('express')
var bodyParser = require('body-parser')

const app = express()
const port = 3000
//访问静态页面
app.use(express.static('www'))
//访问上传的文件
app.use('/uploads',express.static('uploads'))
//解析body中间件
app.use(bodyParser.json({limit:'100mb'}))
 
//设置跨域访问
app.all('*',function(req,res,next){
    //允许的域名
    res.header("Access-Control-Allow-Origin","*");
    //跨域允许的请求方式 
    res.header("Access-Control-Allow-Methods","POST, GET, OPTIONS, DELETE,PUT");
    //允许的header类型
    res.header("Access-Control-Allow-Headers","X-Requested-With");
    res.header('Access-Control-Allow-Headers','token,content-type');
    next();
});

//wx
const wxRouter = require('./wx')
wxRouter(app)

//admin
const adminRouter = require('./admin')
adminRouter(app)

app.listen(port,() => {
    console.log(`Example app listening on port ${port}`)
})